﻿@using Sausage.Web.Models
@using Sausage.Web.DataModel
@using Telerik.Web.Mvc.UI
@using Sausage.Web.Domain
@using Sausage.Common
@model DictionaryItemListRow
@{
    ViewBag.Title = "工程日志填报";
    Layout = "~/Views/Shared/MainLayout.cshtml";

    //用于保存天气类型信息
    List<string> weatherModels = new List<string>();

    //用于保存项目信息
    List<string> projectModels = new List<string>();

    //查询天气类型信息
    using (SausageEntities entities = new SausageEntities())
    {
        //查询所有角色信息
        foreach (Project item in entities.Project.Where(item => item.OrganizationID == Helper.CurrentPrincipal.Organization.OrganizationID && item.State == (int)ProjectStateEnum.Audited).OrderBy(item => item.ProjectName).ToArray())
        {
            //转换为字符串
            projectModels.Add(string.Format(@"{{ ID: '{0}', Code: '{1}', Name:'{2}' }}", item.ProjectID, item.ProjectCode, item.ProjectName));
        }
               
        //查询所有机械类型信息
        foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 10).OrderBy(item => item.ItemName).ToArray())
        {
            //判断是否为空字符
            if (string.IsNullOrEmpty(item.ItemPinYin))
            {
                //转换为字符串
                weatherModels.Add(string.Format(@"{{ Name: '{0}', PinYin: '{0}' }}", item.ItemName, item.ItemName));
            }
            else
            {
                //转换为字符串
                weatherModels.Add(string.Format(@"{{ Name: '{0}', PinYin: '{1} {2}' }}", item.ItemName, item.ItemPinYin, item.ItemName));
            }
        }
    }    
}
@section HeadCssLink
{
    <link href="@Url.Content("~/Content/Styles/ext-patch.css")" rel="stylesheet" type="text/css" />
    <link  href="@Url.Content("~/Content/Styles/images_viewer.css")" rel="stylesheet" type="text/css" />
}
@section HeadScriptLink
{
    <script src="@Url.Content("~/Scripts/ExtJS/locale/ext-lang-zh_CN.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/model.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Sausage/ProjectJournal/Submit.js")" type="text/javascript"></script>
    <script type="text/javascript">
        //保存会话编号
        var session_id = '@Html.Raw(Session.SessionID)';
        //保存认证编号
        var auth_id = '@Html.Raw(Request.Cookies[FormsAuthentication.FormsCookieName].Value)';

        //用于保存项目信息
        var master_project =
        [
            @Html.Raw(System.String.Join(",", projectModels))
        ];

        //用于保存项目信息存储
        var store_master_project = null;

        //用于保存天气类型信息
        var master_weather_type =
        [
            @Html.Raw(System.String.Join(",", weatherModels))
        ];

        //天气类型存储
        var store_master_weather = null;

        //图片存储
        var store_photo = null;

        //用于保存文件存储
        var store_files = null;
    </script>
}
<h2>
    @ViewBag.Title
</h2>
<br />
<div id="data-grid" class="div-grid-box">
</div>
